#include <stdio.h>
#define m 4
#define n 4
int main() {
    int arr[n] = { 0 };
    for (int i = 0; i < n; ++i) {
        scanf("%d", &arr[i]);
    }
    getchar();
    int arr2[m] = { 0 };
    for (int i = 0; i < m; ++i) {
        scanf("%d", &arr2[i]);
    }

    int flag;
    for (int i = 0; i < n; ++i) {
        if (i != n - 1) {
            flag = 0;
            for (int j = 0; j < m; ++j) {
                if (arr[i] == arr2[j]) {
                    flag = 1;
                    break;
                }
            }
            printf("%d ", arr[i]);
        }
        else {
            flag = 0;
            for (int j = 0; j < m; ++j) {
                if (arr[i] == arr2[j]) {
                    flag = 1;
                    break;
                }
            }
            printf("%d", arr[i]);
        }
    }
    return 0;
}
